package main.niit.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCUtils {
    public static Connection getConnection() throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://192.168.11.128:3306/niitproject6?serverTimezone=Asia/Shanghai";
        Connection connection = DriverManager.getConnection(url,"root","root");
        return connection;
    }

    public static void close(PreparedStatement ps,Connection connection){
        if(ps != null){
            try{
                ps.close();
            }catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (connection != null){
            try{
                connection.close();
            }catch (SQLException e) {
                e.printStackTrace();
            }
        }
}
}

